<div class="findtrs" >
	<form action="" class="layui-inline layui-form" method="post" style="width: 100%;">
		<div class="ftitle">
			<div class="lt">
				<h2>实名认证</h2>
			</div>
		</div>
		<div class="fremittanpred fbai" >
			<div class="list">
				<ul>
					<li style="min-width: 450px;">
						<label>名 <i>*</i></label>
						<input type="text" class="info" name="first_name" lay-verify="required" lay-verType="tips" placeholder="请输入first_name" >
						<br />
						<label>姓 <i>*</i></label>
						<input type="text" class="info" name="last_name" lay-verify="required" lay-verType="tips" placeholder="请输入last_name" >
						<br />
						<label>身份证号码 <i>*</i></label>
						<input type="text" class="info" name="user_card" lay-verify="required" lay-verType="tips" placeholder="请输入身份证号码" >
						<br />
						<label>验证码 <i>*</i></label>
						<div class="layui-form-item" id="captcha_div">
							<div class="layui-col-xs7">
								<input type="text" style="border-radius: 7px" name="captcha" id="captcha_ipt" value=""  lay-verType="tips"
									   lay-verify="required" placeholder="{:lang('请输入验证码')}" class="layui-input" maxlength="4">
							</div>
							<div class="layui-col-xs5">
								<div style="margin-left: 10px;">
									<img src="{:url('verify/index')}" id="captcha_img" onclick="setCaptcha()" title="{:lang('change vercode')}" alt="captcha" style="max-width:120px;cursor:pointer;" />
								</div>
							</div>
						</div>
						<i style="font-size: 20px;">* 获取二维码后,请扫码完成用户信息提交
							</span><br/><br/>
						</i>
						<i style="font-size: 20px;color: red">* 请正确填写正确信息，错误信息会认证失败.
							</span><br/><br/>
						</i>
						<div class="fbottonlst" style="float: left;">
							<ul style="justify-content: left;min-width: 350px">
								<li class="on">
									<input type="button" class="fsubmit" lay-submit lay-filter="edit" style="float: left" value="提 交" >
								</li>
							</ul>
						</div>
					</li>
					<li style="padding-left: 20px;min-width: 550px;">
						<span id="XXX"></span><br />
						<span id="time_show" style="color: red;font-weight: bold;font-size: 18px;display: none">
							请在:
							<!--							<strong id="hour_show"><s id="h"></s>0时</strong>-->
							<strong id="minute_show"><s></s>00分</strong>
							<strong id="second_show"><s></s>00秒</strong>
							内完成提交
						</span>
					</li>
					<input type="hidden" name="sessionId" id="sessionId" value="">
				</ul>
			</div>

		</div>
	</form>
	<div class="funaduibi fbai">
		<div class="fdbtable qmfdbtable ftable fboxbai">
			<table border="0" cellspacing="0" cellpadding="0" width="100%" id="dataTable">
			</table>
		</div>
	</div>
</div>
<script type="text/javascript">
	layui.use(['form','table'], function() {
		var form = layui.form,
				table = layui.table; //表格

		table.render({
			elem: '#dataTable',
			height: 'auto',
			cellMinWidth: '80',
			totalRow: true,
			method: 'post',
			url: "{:url('idList')}",
			id: 'dataTable1',
			text:{none: '无数据'},
			cols: [[
				{ type: 'numbers'},
				{ field: 'time', align: 'center', title: '时间' ,
					templet: function (d) {
						return layui.util.toDateString(d.time * 1000, "yyyy-MM-dd HH:mm:ss");
					}
				},
				{ field: 'name',align: 'center', title: '姓名'},
				{ field: 'id_number',align: 'center', title: '身份证'},
				{ field: 'is_rep',align: 'center', title: '审核结果'},
				{ field: 'remark',  align: 'left', title: '描述' },

			]],
			page: true,
			limit: 10,
			limits: [10],
		});

		form.on('submit(edit)', function(data){
			// $("#time_show").show();
			// timer("120");
			// return false;
			var loading =layer.load(1, {shade: [0.1,'#fff']});
			JsPost("{:url('idCheck')}", data.field, function(res){
				layer.close(loading);
				console.log(res.code);
				if(res.code != undefined && res.code >0){
					layer.msg(res.msg, {time:1500}, function(){
						$("#time_show").show();
						timer("1800");
						$("#XXX").html('');
						$("#XXX").qrcode(res.data.url);
						$("#sessionId").val(res.data.session_id);

					});
					// window.location.href = "{:url('fund/index')}";
				}else{
					setCaptcha();
					if(res.msg != undefined){
						layer.msg(res.msg , {time:1500});
					}else{
						layer.msg('提交失败' , {time:1500});
					}
				}
			})
		});
	});

	//更改验证码图片
	setCaptcha = function() {
		$('#captcha_ipt').val("");
		var timestamp = new Date().getTime();
		$('#captcha_img').attr('src', '{:url(\'verify/index\')}?' + timestamp);
	}

	var myTimer;
	var intDiff=1;
	$(document).ready(function() {
		index = setInterval("ajaxstatus()", 3000);
	});
	function ajaxstatus() {
		if(intDiff>0){
			var date = new Date();
			var timer = date.getTime().toString();
			$.ajax({
				url:"{:url('idCheckVef')}?s_id=" + $("#sessionId").val() + "&t=" + timer,
				type: "GET",
				dataType: "json",
				success: function(res) {
					const check = res;
					if(check) { //订单状态为1表示支付成功
						layer.msg('身份认证成功.' , {time:1500});
						window.location.href = "{:url('user/account')}";
					}
				},
				error: function() {

				}
			});
		}
	}
	function timer(intDiff) {
		myTimer = window.setInterval(function () {
			var day = 0,
					hour = 0,
					minute = 0,
					second = 0;//时间默认值
			if (intDiff > 0) {
				day = Math.floor(intDiff / (60 * 60 * 24));
				// hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
				minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
				second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
			}
			if (minute <= 9) minute = '0' + minute;
			if (second <= 9) second = '0' + second;
			// $('#hour_show').html('<s id="h"></s>' + hour + '时');
			$('#minute_show').html('<s></s>' + minute + '分');
			$('#second_show').html('<s></s>' + second + '秒');
			if (hour <= 0 && minute <= 0 && second <= 0) {
				intDiff = 0;
				window.location.href = "{:url('user/account')}";
				clearInterval(myTimer);
			}
			intDiff--;

		}, 2000);
	}
</script>